﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.SpriteRenderer
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Events;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Renders a Sprite for 2D graphics.</para>
  /// </summary>
  [NativeType("Runtime/Graphics/Mesh/SpriteRenderer.h")]
  [RequireComponent(typeof (Transform))]
  public sealed class SpriteRenderer : Renderer
  {
    private UnityEvent<SpriteRenderer> m_SpriteChangeEvent;

    public void RegisterSpriteChangeCallback(UnityAction<SpriteRenderer> callback)
    {
      if (this.m_SpriteChangeEvent == null)
        this.m_SpriteChangeEvent = new UnityEvent<SpriteRenderer>();
      this.m_SpriteChangeEvent.AddListener(callback);
    }

    public void UnregisterSpriteChangeCallback(UnityAction<SpriteRenderer> callback)
    {
      if (this.m_SpriteChangeEvent == null)
        return;
      this.m_SpriteChangeEvent.RemoveListener(callback);
    }

    [RequiredByNativeCode]
    private void InvokeSpriteChanged()
    {
      try
      {
        this.m_SpriteChangeEvent?.Invoke(this);
      }
      catch (Exception ex)
      {
        Debug.LogException(ex, (Object) this);
      }
    }

    internal extern bool shouldSupportTiling { [NativeMethod("ShouldSupportTiling"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>The Sprite to render.</para>
    /// </summary>
    public extern Sprite sprite { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>The current draw mode of the Sprite Renderer.</para>
    /// </summary>
    public extern SpriteDrawMode drawMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Property to set or get the size to render when the SpriteRenderer.drawMode is set to SpriteDrawMode.Sliced or SpriteDrawMode.Tiled.</para>
    /// </summary>
    public Vector2 size
    {
      get
      {
        Vector2 ret;
        this.get_size_Injected(out ret);
        return ret;
      }
      set => this.set_size_Injected(ref value);
    }

    /// <summary>
    ///   <para>The current threshold for Sprite Renderer tiling.</para>
    /// </summary>
    public extern float adaptiveModeThreshold { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>The current tile mode of the Sprite Renderer.</para>
    /// </summary>
    public extern SpriteTileMode tileMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Rendering color for the Sprite graphic.</para>
    /// </summary>
    public Color color
    {
      get
      {
        Color ret;
        this.get_color_Injected(out ret);
        return ret;
      }
      set => this.set_color_Injected(ref value);
    }

    /// <summary>
    ///   <para>Specifies how the sprite interacts with the masks.</para>
    /// </summary>
    public extern SpriteMaskInteraction maskInteraction { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Flips the sprite on the X axis.</para>
    /// </summary>
    public extern bool flipX { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Flips the sprite on the Y axis.</para>
    /// </summary>
    public extern bool flipY { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Determines the position of the Sprite used for sorting the SpriteRenderer.</para>
    /// </summary>
    public extern SpriteSortPoint spriteSortPoint { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    [NativeMethod(Name = "GetSpriteBounds")]
    internal Bounds Internal_GetSpriteBounds(SpriteDrawMode mode)
    {
      Bounds ret;
      this.Internal_GetSpriteBounds_Injected(mode, out ret);
      return ret;
    }

    internal Bounds GetSpriteBounds() => this.Internal_GetSpriteBounds(this.drawMode);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_size_Injected(out Vector2 ret);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void set_size_Injected(ref Vector2 value);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_color_Injected(out Color ret);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void set_color_Injected(ref Color value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void Internal_GetSpriteBounds_Injected(SpriteDrawMode mode, out Bounds ret);
  }
}
